<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> 
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
    
	
	<title>_调拨审核</title>
	
	<script type="text/javascript">
       $(function() {
	     $("#queryForm").validate(); 
		 $("#_fromDate").datepicker({ format:'yyyy-mm-dd'});
		 $("#_toDate").datepicker({ format:'yyyy-mm-dd'});
       });
       
       var sel_userId; 
       var sel_allotId;
       
       function openWindow(allotId){
          $("input[name='checkUser']").attr("checked",false);
          sel_userId="";
          sel_allotId=allotId;
       }
       
       function check(userId){
          var id="check_"+userId;
          $("input[name='checkUser']").attr("checked",false);
          $("#"+id).attr("checked",true);
          sel_userId=userId;
       }
       
       function commandTask(){
       
         if(sel_userId==""){
            alert("请选择拣货执行人...");
         }else{
           $("#userId").val(sel_userId);
           $("#allotId").val(sel_allotId);
           $("#inputForm").submit();
         }
         
       }
       
    </script>
</head>

<body>
    <c:if test="${not empty message}">
		<div id="message" class="alert alert-success"><button data-dismiss="alert" class="close">×</button>${message}</div>
	</c:if>
	
	<div style="height: 10px;"></div>
	
	<div class="row">
		<div class="span12" style="margin-left: 20px;">
			<form class="form-search" id="queryForm" action="${ctx}/allotAudit" method="post">
			
				<label style="margin-left:10px;">调出仓库：</label> 
				<select  name="_outstorageCode"  id="_outstorageCode" value="${param._outstorageCode}"  class="input-medium">
					<option value=""></option>
					<c:forEach items="${areagroupList}" var="areagroup">
						<option value="${areagroup.groupCode}"
						<c:if test="${param._outstorageCode eq areagroup.groupCode}">selected=selected</c:if>
						>${areagroup.groupName}</option>
					</c:forEach>
				</select>
				
				<label style="margin-left:10px;">调入仓库：</label> 
				<select  name="_instorageCode"  id="_instorageCode" value="${param._instorageCode}"  class="input-medium">
					<option value=""></option>
					<c:forEach items="${areagroupList}" var="areagroup">
						<option value="${areagroup.groupCode}"
						<c:if test="${param._instorageCode eq areagroup.groupCode}">selected=selected</c:if>
						>${areagroup.groupName}</option>
					</c:forEach>
				</select>
				
			    <label style="margin-left:10px;">审核状态：</label> 
				<select  name="_statusFlag"  id="_statusFlag" value="${_statusFlag}" class="input-medium">
					<option value="all"></option>
					    <option value="1"  <c:if test="${_statusFlag eq '1'}">selected=selected</c:if>>待审核...</option>
						<option value="4" <c:if test="${_statusFlag eq '4'}">selected=selected</c:if>>待指派任务...</option>
				</select>
				
				<label>&nbsp;&nbsp;&nbsp;申请日期&nbsp;&nbsp;&nbsp;从：</label> 
			 	<input type="text" name="_fromDate" id="_fromDate"  class="input-medium" value="${_fromDate}" style="margin-left: -10px;"> 
			 	<label>至：</label> 
			 	<input type="text" name="_toDate" id="_toDate" class="input-medium" value="${_toDate}" style="margin-left: -10px;"> 
			 	
			    <button id="query_btn" type="submit" class="btn" style="margin-left: 10px;">搜索</button>
		    </form>
	    </div>
	</div>
	
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead><tr>
		    <th style="width: 150px;">调拨单号</th>
		    <th style="width: 130px;">调出仓库</th>
		    <th style="width: 130px;">调入仓库</th>
		    <th style="width: 130px;">当前环节</th>
		    <th style="width: 130px;">申请人</th>
		    <th style="width: 150px;">申请时间</th>
			<th >操作</th>
		</tr></thead>
		<tbody>
		<c:forEach items="${page.content}" var="allot">
			<tr>
			    <td>${allot.allotCode}</td>
			    <td>${allot.outstorage.groupName}</td>
			    <td>${allot.instotrage.groupName}</td>
			    <td>
			      <c:if test="${allot.status eq '1' }">发起申请</c:if>
			      <c:if test="${allot.status eq '2' }">审核通过</c:if>
			      <c:if test="${allot.status eq '3' }">审核驳回</c:if>
			      <c:if test="${allot.status eq '4' }">创建拣货任务</c:if>
			      <c:if test="${allot.status eq '5' }">拣货任务指派</c:if>
			      <c:if test="${allot.status eq '6' }">拣货任务完成</c:if>
			      <c:if test="${allot.status eq '7' }">打包</c:if>
			      <c:if test="${allot.status eq '8' }">已出库</c:if>
			      <c:if test="${allot.status eq '9' }">分仓入库</c:if>
			      <c:if test="${allot.status eq '10' }">调拨完成</c:if>
			    </td>
			    <td>${allot.requester.realname}</td>
			    <td>${fn:substring(allot.requestTime,0,19)}</td>
				<td>
				   <c:if test="${allot.status eq '1'}">
				      <a href="${ctx}/allotAudit/toAudit/${allot.id}" class="btn btn-primary ">进入审核</a>
				   </c:if>
				   
				   <c:if test="${allot.status ne '1'}">
				      <input type="button"  disabled="disabled"  class="btn" value="进入审核"/>
				   </c:if>
				   
				   <c:if test="${allot.status eq '4'}">
				      <a  href="#selectTasker" role="button" data-toggle="modal" class="btn btn-primary" onclick="openWindow('${allot.id}');" style="margin-left: 10px;" >指派拣货任务</a>
				   </c:if>
				   
				   <c:if test="${allot.status ne '4'}">
				      <input type="button"  disabled="disabled"  class="btn" value="指派拣货任务"/>
				   </c:if>
				   
				</td>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<tags:pagination page="${page}" paginationSize="5"/>
	
	
	<!-- 指派任务 ------------------------------------------------------------------------------->
	<div style="display:none; width:550px;" class="modal hide fade" role="dialog"  id="selectTasker" >
		<!-- 头 -->
		<div class="modal-header"  >
			<font  size="4"><b>选择任务执行人</b></font>
		</div>
		<!-- 体 -->
		<div class="modal-body" style="height: 230px;">
		
		     <table id="contentTable" class="table table-striped table-bordered table-condensed">
				<thead><tr>
					<th>姓名</th>
					<th>选择</th>
				</tr></thead>
				<tbody id="userInfo">
				  <c:forEach items="${userList}" var="user">
				     <tr>
                        <td>${user.realname}</td>	
                        <td><input type="checkbox" id="check_${user.id}" name="checkUser" onclick="check('${user.id}')" /></td>	
				     </tr>
				  </c:forEach>
				</tbody>
			</table>
			
		</div>
		
		<!-- 尾 -->
		<div class="modal-footer">
		 <form id="inputForm" action="${ctx}/allotTask/commandTask" method="post" class="form-horizontal">
		    <input  type="hidden"  name="allotId" id="allotId"/>
		    <input  type="hidden"  name="userId" id="userId"/>
			<a class="btn"  onclick="commandTask();" >指派任务</a>
			<a class="btn" id="cancel" data-dismiss="modal" aria-hidden="true">取消</a>
	     </form>
		</div>
		
		
    </div>
	<!-- 选择批次窗体 ------------------------------------------------------------------------------->
	
	
</body>
</html>
